const { DataTypes } = require('sequelize');
const sequelize = require('../config/database');
const User = require('./User');
const SheetMusic = require('./SheetMusic');

const StudyNote = sequelize.define('StudyNote', {
  id: {
    type: DataTypes.INTEGER,
    primaryKey: true,
    autoIncrement: true
  },
  title: {
    type: DataTypes.STRING,
    allowNull: false
  },
  content: {
    type: DataTypes.TEXT,
    allowNull: false
  }
});

// 设置关联关系
StudyNote.belongsTo(User, { foreignKey: 'userId' });
User.hasMany(StudyNote, { foreignKey: 'userId' });

StudyNote.belongsTo(SheetMusic, { foreignKey: 'sheetMusicId' });
SheetMusic.hasMany(StudyNote, { foreignKey: 'sheetMusicId' });

module.exports = StudyNote; 